<cfcomponent>
<cffunction name="GET" returntype="any">

</cffunction>

<cffunction name="POST" returntype="any">

</cffunction>



<cffunction name="is_area" returntype="any">
<cfargument required="no" name="id" default="">
<cfargument required="no" name="prac_id" default="">
<cfquery datasource="#Session.dsn#" name="query_results">
select * from practitioner_detail where practitioner_id = '#prac_id#'
</cfquery>


<cfloop from="1" to="#ListLen(query_results.five_star_area)#" index="i">
<cfset tmp = listgetat(query_results.five_star_area,i)>
<cfif tmp eq 0></cfif>
</cfloop>
</cffunction>



<cffunction name="search" returntype="any">
<cfargument required="no" name="search_term_1" default="not_selected">
<cfargument required="no" name="search_term_2" default="not_selected">
<cfargument required="no" name="search_term_3" default="not_selected">
<cfargument required="no" name="search_term_4" default="">
<cfargument required="no" name="search_term_5" default="">


<cfquery datasource="#Session.dsn#" name="search_results">
select * 
from practitioner_detail
where 0=0 and 
<cfif search_term_1 neq "not_selected">
five_star_area like '%#search_term_1#%' and
<cfelseif search_term_2 neq "not_selected">
five_star_category like '%#search_term_2#%' and
<cfelseif search_term_3 neq "not_selected">
overall_level_of_expertise = '#search_term_3#' and
<cfelseif search_term_4 neq "" >
availability_start >= '#dateformat(search_term_4)#' and 
<cfelseif search_term_5 neq "">
availability_end <= '#dateformat(search_term_5)#' and
</cfif>
2=2
ORDER BY last_name
</cfquery>


<cfset result = "">
<CFIF isdefined("FORM.starting_term")>
<CFSET starting_term = FORM.starting_term>
<cfelseif isdefined("url.starting_term")>
<CFSET starting_term = url.starting_term>
<CFELSE>

<CFSET starting_term = 1>

</CFIF>
<CFSET end_term = starting_term + 9>
<CFSET previous_term = starting_term - 10>
<CFIF previous_term LT 1>
<CFSET previous_term = 1>
</CFIF>
<CFSET last_term = search_results.RecordCount - 9>
<CFIF starting_term + 9 GT search_results.RecordCount - 9>
<CFSET next_term = search_results.RecordCount - 9>
<CFELSE>

<CFSET next_term = starting_term + 10>

</CFIF>

<!--- Build search results table --->


<!--- No Results --->

<cfset search_term = "">
<Cfset result = "<form method='post' name='delete' action='report_add.cfm'>
<table border='0' cellspacing='0' cellpadding='0' width='98%'>
<tr>
<td class='greyHeader' >&nbsp;</td>
<td width='' class='greyHeader' >Name</td>
<td class='greyHeader' >Professional Experience</td>
<td class='greyHeader' >5 Star Area</td>
<td class='greyHeader' >Category</td>
<td class='greyHeader' >5 Star Area Experience</td>
<td class='greyHeader' >Category Experience</td>
<td class='greyHeader' >Certification</td>
<td class='greyHeader' >Level of Expertise</td>
<td class='greyHeader' >Availability</td>
<td class='greyHeader' >&nbsp;</td>
</tr>
<CFIF starting_term LT 1>
<CFSET starting_term = 1>
</CFIF>">
<CFLOOP QUERY='search_results' startRow = '#starting_term#' endRow = '#starting_term+9#'>
<Cfset result = result & "
<tr>

<td class='dataRowB'><input type='checkbox' name='delete_#practitioner_id#' value='#practitioner_id#' style='border:1px solid ##FFFFFF;'></td>
<td class='dataRowB' ><div>#first_name# #last_name#&nbsp;</div>
<div></div></td>
<td class='dataRowB' ><div>#overall_level_of_expertise#&nbsp;</div>
<div></div></td>
<td class='dataRowB' ><div>#five_star_area#&nbsp;</div>
<div></div></td>
<td class='dataRowB' ><div>#five_star_category#&nbsp;</div>
<div></div></td>
<td class='dataRowB' ><div>#yrs_five_star_area_experience#&nbsp;</div>
<div></div></td>
<td class='dataRowB' ><div>#yrs_category_experience#&nbsp;</div>
<div></div></td>
<td class='dataRowB' ><div>#certification#&nbsp;</div>
<div></div></td>
<td class='dataRowB' ><div>#overall_level_of_expertise#&nbsp;</div>
<div></div></td>
<td class='dataRowB' ><div>#availability_start# - #availability_end#&nbsp;</div>
<div></div></td>
<td class='dataRowC'  valign='top'><a href='/edit.cfm?id=#search_results.practitioner_id#' target='_blank'>EDIT</a>&nbsp;</td>
</tr><input type='hidden' name='practitioner_id' value='#search_results.practitioner_id#'>">
</CFLOOP>

<Cfset result = result & "
<tr>
<td colspan='11'>
<table width='100%'  border='0' cellspacing='0' cellpadding='0'>
    <tr>
<td class='TrackerNav' width='5%' onMouseOver='this.className='TrackerNavOver';' onMouseOut='this.className='TrackerNav';'>
<a href='/search.cfm?action=search&search_term_1=#search_term_1#&search_term_2=#search_term_2#&search_term_3=#search_term_3#&search_term_4=#search_term_4#&search_term_5=#search_term_5#&starting_term=1'>First</a>
</td>
<td class='TrackerNavB' width='5%' onMouseOver='this.className='TrackerNavOver';' onMouseOut='this.className='TrackerNav';'>
<a href='/search.cfm?action=search&search_term_1=#search_term_1#&search_term_2=#search_term_2#&search_term_3=#search_term_3#&search_term_4=#search_term_4#&search_term_5=#search_term_5#&starting_term=#previous_term#'>Previous</a>
</td>
<td class='TrackerNavMute' width='85%'>&nbsp;</td>
<td class='TrackerNav' width='5%' onMouseOver='this.className='TrackerNavOver';' onMouseOut='this.className='TrackerNav';'>
<a href='?action=search&search_term_1=#search_term_1#&search_term_2=#search_term_2#&search_term_3=#search_term_3#&search_term_4=#search_term_4#&search_term_5=#search_term_5#&starting_term=#next_term#'>Next</a>
</td>
<td class='TrackerNavB' width='5%' onMouseOver='this.className='TrackerNavOver';' onMouseOut='this.className='TrackerNav';'>
<a href='/search.cfm?action=search&search_term_1=#search_term_1#&search_term_2=#search_term_2#&search_term_3=#search_term_3#&search_term_4=#search_term_4#&search_term_5=#search_term_5#&starting_term=#last_term#'>Last</a>
</td>
</tr>
<tr><td>&nbsp;</td></tr>
<tr><td colspan='11' align='left'><input type='submit' name='submit' value='Add Selected To 5 Star Report' align='left' class='button'></td></tr>
  </table></td>
</tr>

</table>
</form>
">

<cfreturn result>


</cffunction>

<!--- Function to remove slash at beginning of string if there. --->
<cffunction access="public" name="remove_slash_from_beginnning_of_string" returntype="string">
	<cfargument name="temp_string" default="" required="yes">
	<cfif Left(temp_string, 1) EQ "/">
		<cfset temp_string = Right(temp_string, len(temp_string)-1)>
	</cfif>
	<cfreturn temp_string>
</cffunction>

<!--- Function to add slash at end of string if not there already. --->
<cffunction access="public" name="add_slash_to_end_of_string" returntype="string">
	<cfargument name="temp_string" default="" required="yes">
	<cfif Right(temp_string, 1) NEQ "/">
		<cfset temp_string=temp_string & "/">
	</cfif>
	<cfreturn temp_string>
</cffunction>

<!--- Function to remove comma from end of string if there. --->
<cffunction access="public" name="remove_comma_from_end_of_string" returntype="string">
	<cfargument name="temp_string" default="" required="yes">
	<cfif Right(temp_string, 1) EQ ",">
		<cfset temp_string = Left(temp_string, Len(temp_string)-1)>
	</cfif>	
	<cfreturn temp_string>
</cffunction>

<!--- Function to get last term in CGI.PATH_INFO. --->
<cffunction access="public" name="get_last_term_in_path" returntype="string">
<cfargument name="temp_string" default="#CGI.PATH_INFO#" required="yes">
	<cfif Right(temp_string, 1) EQ "/">
		<cfset temp_string = Left(temp_string, len(temp_string)-1)>
	</cfif>
	<cfset temp_string = Reverse(temp_string)>
	<cfset temp_string = Left(temp_string, FindOneOf("/", temp_string)-1)>
	<cfset temp_string = Reverse(temp_string)>
	<cfreturn temp_string>
</cffunction>

<!--- Function to add backslash escapement to a string(JSON) --->
<cffunction access="public" name="add_json_escapement" returntype="string">
<cfargument name="temp_string" default="" required="yes">
	<cfset temp_string = Replace(temp_string, "\", "\\", "ALL")>
	<cfset temp_string = Replace(temp_string, chr(34),"&quot;", "ALL")>
	<cfreturn temp_string>
</cffunction>


<cffunction access="public" name="get_base_path" returntype="string">
    <cfreturn GetDirectoryFromPath(GetBaseTemplatePath())>
</cffunction>




</cfcomponent>